pub struct Solution;

impl Solution {
    pub fn repeated_substring_pattern(s: String) -> bool {
        if s.len() == 1 { return false; };
        let mut result = false;
        let x = s.chars().collect::<Vec<char>>();

        'outter: for v in (1..=s.len() / 2).into_iter().rev() {
            let mut prev = String::new();
            let vec = x.chunks(v)
                .map(|v| v.iter().collect::<String>())
                .collect::<Vec<String>>();
            let mut flag = true;
            'inner: for a in vec {
                if !prev.is_empty() {
                    if prev != a {
                        flag = false;
                        break 'inner;
                    }
                } else {
                    prev = a;
                }
            }
            if flag {
                result = flag;
                break 'outter;
            }
        }
        result
    }
}